package com.hei.kml.converter;

import com.hei.kml.validator.Validator;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.StaxDriver;

public interface KMLConverter<T> {

	default T fromKML(String xml) {
		// todo kml转对象
		throw new UnsupportedOperationException();
	}

	default String toKML() {
		if (this instanceof Validator) ((Validator) this).validate();

		XStream xstream = new XStream(new StaxDriver());
		xstream.processAnnotations(this.getClass());
		return xstream.toXML(this);
	}

}
